Repository navigation
feat: installable app with offline service worker - #26
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes tools.halit.org an installable web app that keeps working offline.
Manifest
/site.webmanifest(id and start/) and/tr/site.webmanifest(id and start/tr/). Both have scope/, so the Turkish pages and the English ones open inside either installed app. Separate ids mean a Turkish install opens at/tr/and the two manifests never overwrite each other.display: standalone, white theme and background (from the tokens), the existing 192, 512 and maskable icons, and shortcuts to the first four tools of each language in index order.apple-mobile-web-app-title;apple-touch-iconand boththeme-colormetas were already there.Service worker (
src/sw.js, served at/sw.js)?v=<hash of css and js>to every CSS and JS URL, including module imports, so a worker from an older deploy cannot answer a newer page's assets from its cache.tools-<hash>, a hash of every precached file computed inbuild.mjs. Install precaches all 25 pages plus their scripts,site.css, fonts, icons and manifests (74 files) withcache: "reload", then callsskipWaiting. Activate deletes the othertools-*caches and claims clients.Fonts
Geist is now self-hosted from
public/fonts/(the same Google Fonts woff2 subsets, OFL license included), so the font works offline. The CSP dropsfonts.googleapis.comandfonts.gstatic.comand addsworker-src 'self'. The only outside connection left is the Cloudflare beacon, which is now exactly what the "How these tools work" copy says.Install button
A quiet nav button ("Install app" / "Uygulamayı yükle", "Install" / "Yükle" on phones, icon only below 380px) with an inline SVG icon.
beforeinstallprompt, then it opens the browser's prompt once and hides.display-mode: standaloneornavigator.standalone) and in browsers with no install path (Firefox, desktop Safari).Checks
npm test: 183 pass.node scripts/browser-check.mjs(the full check): passed locally this time.npm run check:pwa(scripts/pwa-check.mjs): manifests are linked and valid on every page, and Chrome'sPage.getAppManifestreports no errors.Page.getInstallabilityErrorsis empty for/and/tr/(run in a real profile). The worker registers with scope/and precaches everything. With the server down and the context offline, all 25 pages load with CSS and Geist, text compare still runs, and an unknown/tr/URL falls back to/tr/. A changed page shows at once while the network is up, and a new worker hash replaces the old cache. The install button covers the fake prompt at 1280 and 390, standalone mode and the iOS hint. No console or CSP errors.